package com.book.common.utils;

import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;

import java.net.URI;

/***
 * @Author Lin
 * @Date Create By 21:13 2017/10/6
 * @Description
 */
public class NovelSpiderHttpGet extends HttpGet {

    public NovelSpiderHttpGet() {
    }

    public NovelSpiderHttpGet(URI uri) {
        super(uri);
    }

    public NovelSpiderHttpGet(String url) {
        super(url);
        setDefaultConfig();
    }

    private void setDefaultConfig() {
        this.setConfig(RequestConfig.custom()
                .setSocketTimeout(5_000)
                .setConnectTimeout(10_000)            //设置连接服务器的超时时间
                .setConnectionRequestTimeout(10_000)  //设置从服务器读取数据的超时时间
                .build());
        this.setHeader("User-Agent","NovelSpider");
    }
}
